import { Exclude, Expose, Transform } from 'class-transformer';
import { Init } from 'src/common/entities/init.entity';
import { Column, Entity, PrimaryColumn, PrimaryGeneratedColumn } from 'typeorm';

@Entity({
  comment: '用户表',
})
export class User extends Init {
  @PrimaryGeneratedColumn()
  @PrimaryColumn({
    type: 'int',
    name: 'user_id',
    comment: '用户id',
  })
  userId: number;

  @Column({
    type: 'varchar',
    name: 'nick_name',
    length: 255,
    comment: '名字',
    default: '微信用户',
  })
  nickName: string;

  @Column({
    type: 'boolean',
    name: 'is_vip',
    default: false,
    comment: '是否为VIP',
  })
  isVip: boolean;

  @Column({
    type: 'int',
    name: 'vip_level',
    default: 0,
    comment: 'VIP等级',
  })
  vipLevel: number;

  @Column({
    type: 'varchar',
    name: 'open_id',
    length: 255,
    comment: '微信唯一标识',
  })
  @Exclude()
  openId: string;

  @Column({
    type: 'varchar',
    name: 'avatar_image',
    length: 255,
    comment: '用户头像',
    default: 'http://117.72.16.70:2002/static/avatar.png',
  })
  avatarImage: string;

  @Column({
    type: 'varchar',
    name: 'phone',
    length: 255,
    comment: '手机号',
    nullable: true,
  })
  phone: string;
}
